﻿using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using VO.Business.Controllers;
using VO.Business.Utils;
using VO.Entities;

namespace VO.Web
{
    public partial class UserProfilePublic : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gvUserTracks.DataSourceID = string.Empty;
                gvUserDoneTracks.DataSourceID = string.Empty;

                if (Page.RouteData.Values["userId"] != null)
                {
                    int userId = Convert.ToInt32(Page.RouteData.Values["userId"]);
                    Entities.User user = UsersController.GetUser(userId); 
                    lblPublicName.Text = user.PublicName;
                    txtDescription.Text = user.UserDescription;
                    imgUserLogo.ImageUrl = string.Format("~/UserLogo.ashx?uid={0}", user.Id);
                }
            }

                
        }

        protected void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
        {
            switch (TabContainer1.ActiveTabIndex)
            {
                case 0:
                    gvUserTracks.DataSourceID = string.Empty;
                    gvUserDoneTracks.DataSourceID = string.Empty;
                    break;
                case 1:
                    gvUserDoneTracks.DataSourceID = string.Empty;
                    gvUserTracks.DataSourceID = "odsUserTracks";
                    //
                    break;
                case 2:
                    gvUserDoneTracks.DataSourceID = "odsUserDoneTracks";
                    gvUserTracks.DataSourceID = string.Empty;
                    break;
                default:
                    break;
            }
        }

    }
}